package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;

import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import com.sky.dto.OrdersConfirmDTO;

@RestController("a")
@Api(tags = "接单")
@RequestMapping("/admin/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    @PutMapping("/confirm")
    public Result confirm(@RequestBody OrdersConfirmDTO dto){
        orderService.confirm(dto);
        return Result.success();

    }
    @PutMapping("/rejection")
    @ApiOperation("拒单")
    public Result rejection(@RequestBody OrdersRejectionDTO dto){
        orderService.rejection(dto);
        return Result.success();



    }@ApiOperation("取消订单")
    @PutMapping("/cancel")
    public Result cancel(@RequestBody OrdersCancelDTO dto){
        orderService.cancel(dto);
        return Result.success();


    }
    @PutMapping("/delivery/{id}")
    @ApiOperation("派送订单")
    public Result delivery(@PathVariable Long id){
        orderService.delivery(id);
        return Result.success();

    }
    @PutMapping("/complete/{id}")
    @ApiOperation("完成订单")
    public Result complete(@PathVariable Long id){
        orderService.complete(id);
        return  Result.success();

    }



    @ApiOperation("订单搜索")
    @GetMapping("/conditionSearch")
    public Result selectOrder(OrdersPageQueryDTO dto){
        PageResult pageResult = orderService.selectOrder(dto);
        return Result.success(pageResult);
    }

    @ApiOperation("订单数量统计")
    @GetMapping("/statistics")
    public Result OrderStatistics(){
        OrderStatisticsVO orderStatisticsVO = orderService.OrderStatistics();
        return Result.success(orderStatisticsVO);
    }

    @GetMapping("details/{id}")
    @ApiOperation("订单")
    public Result selectOrderById(@PathVariable Long id){
        OrderVO orderVO = orderService.selectOrderById(id);

        return Result.success(orderVO);
    }


}
